package parser

import (
	"learngo/crawler/config"
	"learngo/crawler/engine"
	"regexp"
)

const cityListRe = `<a href="(http://www.zhenai.com/zhenghun/[0-9a-z]+)"[^>]*>([^<]+)</a>`
func ParserCityList(contents []byte, _ string) engine.ParserResult{
	re := regexp.MustCompile(cityListRe)
	matches := re.FindAllSubmatch(contents, -1)


	result := engine.ParserResult{}
	//取两个城市测试
	//limit :=2
	for _,c := range matches{
		result.Requests = append(result.Requests,engine.Request{
			Url: string(c[1]),
			Parser: engine.NewFuncParser(ParserCity, config.ParseCity),
		})
		//limit--
		//if limit == 0{
		//	break
		//}
	}
	return result
}
